/*
 * Copyright 2003-2007 (c) Live Media Pty Ltd. <argot@einet.com.au> 
 *
 * This software is licensed under the Argot Public License 
 * which may be found in the file LICENSE distributed 
 * with this software.
 *
 * More information about this license can be found at
 * http://www.einet.com.au/License
 * 
 * The Developer of this software is Live Media Pty Ltd,
 * PO Box 4591, Melbourne 3001, Australia.  The license is subject 
 * to the law of Victoria, Australia, and subject to exclusive 
 * jurisdiction of the Victorian courts.
 */

package com.colony.transport.pipe;

import java.io.IOException;

import com.argot.network.TypeEndPoint;
import com.colony.transport.Client;

public class PipeClient
implements Client
{
	private PipeServer _server;

	public PipeClient( PipeServer server )
	{
		_server = server;
	}

	public TypeEndPoint openLink()
	throws IOException
	{
		// Need to pass the other end of the pipe to a server.
		TypeEndPoint ep = _server.openLink();
		ep.getOutputStream().write(10);
		ep.getOutputStream().write(20);
		return ep;
	}

	public void closeLink( TypeEndPoint endPoint )
	{
		try 
		{
			endPoint.getInputStream().close();
		} 
		catch (IOException e) 
		{
			// ignore
		}
		
		try 
		{
			endPoint.getOutputStream().close();
		} 
		catch (IOException e) 
		{
			// ignore
		}
	}

}
